package study.repository.user;

import java.util.List;

import javax.persistence.Query;

import study.domain.user.RoleHierarchy;

import com.barney.support.jpa.CustomRepositorySupport;

public class RoleHierarchyRepositoryImpl extends CustomRepositorySupport
		implements RoleHierarchyRepositoryCustom {

	@SuppressWarnings("unchecked")
	@Override
	public List<RoleHierarchy> getRoleHierarchyList() {
		String sqlString = "SELECT a.* FROM roles_hierarchy a LEFT OUTER JOIN roles_hierarchy b ON a.child_role = b.parent_role";
		Query query = getEntityManager().createNativeQuery(sqlString,
				RoleHierarchy.class);
		return query.getResultList();
	}
}
